﻿<ResourceDictionary
	xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
	xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
    xmlns:Constants="clr-namespace:TfsWorkbench.TaskBoardUI.Constants" 
    xmlns:UIElements="clr-namespace:TfsWorkbench.UIElements;assembly=TfsWorkbench.UIElements"
    >
	<ResourceDictionary.MergedDictionaries>
		<ResourceDictionary Source="CommonElements.xaml"/>
        <ResourceDictionary Source="/TfsWorkbench.UIElements;Component/Resources/ApplicationStyles.xaml"/>
	</ResourceDictionary.MergedDictionaries>

	<SolidColorBrush x:Key="ListBorder" Color="#FF818181"/>

    <Style x:Key="GridScrollViewer_Style" TargetType="{x:Type ScrollViewer}">
        <Setter Property="Focusable" Value="false"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ScrollViewer}">
                    <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <Grid.RowDefinitions>
                            <RowDefinition Height="*"/>
                            <RowDefinition Height="Auto"/>
                        </Grid.RowDefinitions>
                        <DockPanel Margin="{TemplateBinding Padding}">
                            <ScrollViewer Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" DockPanel.Dock="Top">
                                <GridViewHeaderRowPresenter 
                                    Margin="2,0,2,0" 
                                    SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
                                    AllowsColumnReorder="{Binding TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" 
                                    ColumnHeaderContainerStyle="{DynamicResource SwimLaneColumnHeaderStyle}" 
                                    ColumnHeaderContextMenu="{Binding TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" 
                                    ColumnHeaderStringFormat="{Binding TemplatedParent.View.ColumnHeaderStringFormat, RelativeSource={RelativeSource TemplatedParent}}" 
                                    ColumnHeaderTemplate="{Binding TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" 
                                    ColumnHeaderTemplateSelector="{Binding TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" 
                                    ColumnHeaderToolTip="{Binding TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" 
                                    Columns="{Binding TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}"
                                    />
                            </ScrollViewer>
                            <ScrollContentPresenter x:Name="PART_ScrollContentPresenter" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Content="{TemplateBinding Content}" KeyboardNavigation.DirectionalNavigation="Local" CanContentScroll="{TemplateBinding CanContentScroll}"/>
                        </DockPanel>
                        <ScrollBar x:Name="PART_HorizontalScrollBar" Style="{DynamicResource ScrollBarStyle_MainContent}" Cursor="Arrow" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Grid.Row="1" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0.0" Value="{Binding HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}"/>
                        <ScrollBar x:Name="PART_VerticalScrollBar" Style="{DynamicResource ScrollBarStyle_MainContent}" Cursor="Arrow" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Grid.Column="1" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0.0" Value="{Binding VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}"/>
                        <DockPanel Background="{Binding Background, ElementName=PART_VerticalScrollBar}" Grid.Column="1" Grid.Row="1" LastChildFill="false">
                            <Rectangle Fill="White" Width="1" Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" DockPanel.Dock="Left"/>
                            <Rectangle Fill="White" Height="1" Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" DockPanel.Dock="Top"/>
                        </DockPanel>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="RowHeightGripper" TargetType="{x:Type Thumb}">
        <Setter Property="Margin" Value="0,0,0,-4"/>
        <Setter Property="Height" Value="8"/>
        <Setter Property="Padding" Value="0"/>
        <Setter Property="Background" Value="{StaticResource RowResizeGripperBrush}"/>
        <Setter Property="Cursor" Value="SizeNS"/>
        <Setter Property="Tag" Value="RowSizeGripper" />
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type Thumb}">
                    <Border Background="Transparent" Height="{TemplateBinding Height}" />
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="MainListViewStyle" TargetType="{x:Type ListView}">
        <Setter Property="AllowDrop" Value="True" />
        <Setter Property="Background" Value="{x:Null}" />
        <Setter Property="BorderThickness" Value="0" />
        <Setter Property="Foreground" Value="{StaticResource DisplayModeTextColour}"/>
        <Setter Property="ItemContainerStyle">
            <Setter.Value>
                <Style TargetType="{x:Type ListViewItem}">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type ListViewItem}">
                                <Border 
                                    CornerRadius="5" 
                                    Margin="0,5,5,0" 
                                    Padding="0,5,0,5" 
                                    SnapsToDevicePixels="True" 
                                    BorderThickness="0" 
                                    BorderBrush="Transparent" 
                                    Background="{StaticResource SwimLaneItemBackgorund}" 
                                    Effect="{DynamicResource DropShadowLevel1}"
                                    >
                                    <Grid>
                                        <GridViewRowPresenter VerticalAlignment="Stretch" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                                        <Thumb VerticalAlignment="Bottom" Style="{StaticResource RowHeightGripper}" />
                                    </Grid>
                                </Border>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                    <Setter Property="HorizontalContentAlignment" Value="Stretch" />
                </Style>
            </Setter.Value>
        </Setter>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type ListView}">
                    <Border Background="Transparent">
                        <ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource GridScrollViewer_Style}">
                            <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
                        </ScrollViewer>
                    </Border>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
    </Style>

    <Style x:Key="OtherItemListView" TargetType="{x:Type ListView}">
		<Setter Property="VerticalContentAlignment" Value="Stretch"/>
		<Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
        <Setter Property="MinHeight" Value="{x:Static Constants:Numbers.OtherItemsRowHeight}" />
        <Setter Property="Foreground" Value="Black" />
		<Setter Property="ItemContainerStyle">
			<Setter.Value>
				<Style TargetType="{x:Type ListViewItem}">  
					<Setter Property="HorizontalContentAlignment" Value="Stretch" />         
					<Setter Property="Template">
						<Setter.Value>
							<ControlTemplate TargetType="{x:Type ListViewItem}">
							  <Border SnapsToDevicePixels="True" BorderThickness="0" BorderBrush="Transparent" Background="Transparent">
								<GridViewRowPresenter VerticalAlignment="{TemplateBinding VerticalContentAlignment}" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" />
							  </Border>
							</ControlTemplate>
						</Setter.Value>
					</Setter>
				</Style>	
			</Setter.Value>
		</Setter>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type ListView}">
					<Border Background="{StaticResource OtherItemsBackgorund}" CornerRadius="5,5,5,0" Effect="{DynamicResource DropShadowLevel1}">
						<ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource GridScrollViewer_Style}">
							<ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
						</ScrollViewer>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

	<Style x:Key="GridViewColumnHeaderGripper" TargetType="{x:Type Thumb}">
		<Setter Property="Canvas.Right" Value="0"/>
		<Setter Property="Width" Value="18"/>
		<Setter Property="Height" Value="{Binding ActualHeight, RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="Foreground" Value="{Binding Foreground, RelativeSource={RelativeSource TemplatedParent}}"/>
        <Setter Property="Padding" Value="0"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Thumb}">
					<Border Background="Transparent" Padding="{TemplateBinding Padding}">
                        <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Foreground}"/>
					</Border>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>
	
	<Style x:Key="SwimLaneColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
		<Setter Property="HorizontalContentAlignment" Value="Center"/>
		<Setter Property="VerticalContentAlignment" Value="Center"/>
		<Setter Property="BorderThickness" Value="0"/>
		<Setter Property="Padding" Value="2,0,2,0"/>
        <Setter Property="Foreground" Value="{Binding RelativeSource={RelativeSource AncestorType={x:Type ListView}}, Path=Foreground}"/>
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
					<Grid SnapsToDevicePixels="true">
                        <Border x:Name="HeaderBorder">
							<Grid>
								<Grid.RowDefinitions>
									<RowDefinition MaxHeight="7"/>
									<RowDefinition/>
								</Grid.RowDefinitions>
								<Border Padding="{TemplateBinding Padding}" Grid.RowSpan="2">
									<ContentPresenter 
										x:Name="HeaderContent" 
										Cursor="{x:Static UIElements:CustomCursors.Hand}" 
										HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
										Margin="0,0,0,1" 
										VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
										SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
										RecognizesAccessKey="True"
                                        />
								</Border>
							</Grid>
						</Border>
						<Border x:Name="HeaderHoverBorder" Margin="1,1,0,0" BorderThickness="1,0,1,1"/>
						<Border x:Name="HeaderPressBorder" Margin="1,0,0,1" BorderThickness="1,1,1,0"/>
						<Canvas>
                            <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}" Foreground="{TemplateBinding Foreground}" />
						</Canvas>
					</Grid>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
		<Style.Triggers>
			<Trigger Property="Role" Value="Floating">
				<Setter Property="Opacity" Value="0.4082"/>
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
							<Canvas x:Name="PART_FloatingHeaderCanvas">
								<Rectangle Fill="#FF000000" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Opacity="0.4697"/>
							</Canvas>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Trigger>
			<Trigger Property="Role" Value="Padding">
				<Setter Property="Template">
					<Setter.Value>
						<ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
							<Border x:Name="HeaderBorder" BorderThickness="0,1,0,1"/>
							<ControlTemplate.Triggers>
								<Trigger Property="Height" Value="Auto">
									<Setter Property="MinHeight" Value="20"/>
								</Trigger>
							</ControlTemplate.Triggers>
						</ControlTemplate>
					</Setter.Value>
				</Setter>
			</Trigger>
		</Style.Triggers>
	</Style>

    <Style x:Key="OtherItemsColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
        <Setter Property="HorizontalContentAlignment" Value="Center"/>
        <Setter Property="VerticalContentAlignment" Value="Center"/>
        <Setter Property="BorderThickness" Value="0"/>
        <Setter Property="Padding" Value="2,0,2,0"/>
        <Setter Property="Foreground" Value="Black"/>
        <Setter Property="Template">
            <Setter.Value>
                <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                    <Grid SnapsToDevicePixels="true">
                        <Border x:Name="HeaderBorder">
                            <Grid>
                                <Grid.RowDefinitions>
                                    <RowDefinition MaxHeight="7"/>
                                    <RowDefinition/>
                                </Grid.RowDefinitions>
                                <Border Padding="{TemplateBinding Padding}" Grid.RowSpan="2">
                                    <ContentPresenter 
										x:Name="HeaderContent" 
										Cursor="{x:Static UIElements:CustomCursors.Hand}" 
										HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" 
										Margin="0,0,0,1" 
										VerticalAlignment="{TemplateBinding VerticalContentAlignment}" 
										SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" 
										RecognizesAccessKey="True"
                                        />
                                </Border>
                            </Grid>
                        </Border>
                        <Border x:Name="HeaderHoverBorder" Margin="1,1,0,0" BorderThickness="1,0,1,1"/>
                        <Border x:Name="HeaderPressBorder" Margin="1,0,0,1" BorderThickness="1,1,1,0"/>
                        <Canvas>
                            <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}" Foreground="{TemplateBinding Foreground}" />
                        </Canvas>
                    </Grid>
                </ControlTemplate>
            </Setter.Value>
        </Setter>
        <Style.Triggers>
            <Trigger Property="Role" Value="Floating">
                <Setter Property="Opacity" Value="0.4082"/>
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                            <Canvas x:Name="PART_FloatingHeaderCanvas">
                                <Rectangle Fill="#FF000000" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Opacity="0.4697"/>
                            </Canvas>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
            <Trigger Property="Role" Value="Padding">
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                            <Border x:Name="HeaderBorder" BorderThickness="0,1,0,1"/>
                            <ControlTemplate.Triggers>
                                <Trigger Property="Height" Value="Auto">
                                    <Setter Property="MinHeight" Value="20"/>
                                </Trigger>
                            </ControlTemplate.Triggers>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Trigger>
        </Style.Triggers>
    </Style>

</ResourceDictionary>